//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
for chatmessage in agentUserMessageList
    .clearfix.chat-block(id=(chatmessage.id == agentusersearchdetails ? 'agentusersearchdetails' : ''),name=chatmessage.createtime)
        div(class=(chatmessage.calltype && chatmessage.calltype == '呼出' ? 'chat-right' : 'chat-left'))
            img.user-img(alt="", src=(chatmessage.calltype && chatmessage.calltype == '呼出' ? '/images/agent.png' : curagentuser.headimgurl && curagentuser.headimgurl != '' ? curagentuser.headimgurl : '/images/im/user.png'), style='width:45px;height:45px;')
            .chat-message
                span(class=(chatmessage.calltype && chatmessage.calltype == '呼出' ? 'rateright' : 'rateleft'))
                    i.layui-icon.iconclick(id=chatmessage.id, name=(chatmessage.islabel == true ? 'yeslabe' : 'nolabe'), style="font-size:30px;cursor:pointer;color: #{chatmessage.islabel == true ? '#46cad4' : '#aaaaaa'}")
                        | #{chatmessage.islabel == true ? '' : 'စ'}
                span.user
                    if chatmessage && chatmessage.calltype && chatmessage.calltype == '呼出'
                        if chatmessage.intervented
                            | #{chatmessage.supervisorname}
                        else
                            | #{chatmessage.username}
                    else
                        | #{chatmessage.username}
                span.time= pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', chatmessage.createtime)
                span(class=(chatmessage.calltype && chatmessage.calltype == '呼出' ? 'rateleft' : 'rateright'), style="cursor: pointer; font-size: 30px")
                    i.layui-icon.iconclick(id=chatmessage.id, name=(chatmessage.islabel == true ? 'yeslabe' : 'nolabe'), style="cursor:pointer;font-size:30px;color: #{chatmessage.islabel == true ? '#46cad4' : '#aaaaaa'}")
                        | #{chatmessage.islabel == true ? '' : 'စ'}
                div(class=(chatmessage.calltype && chatmessage.calltype == '呼出' ? 'chatting-right' : 'chatting-left'))
                    i.userarrow
                    .chat-content
                        include /apps/agent/media/message.pug
        if agentUserMessageListnum
            input#totalElements(type='hidden',value=agentUserMessageListnum)

style.
    .chat-left .chat-message .rateright {
        display: inline-block;
    }

    .chat-left .chat-message .rateleft {
        display: none;
    }

    .chat-right .chat-message .rateright {
        display: inline-block;
    }

    .chat-right .chat-message .rateleft {
        display: none;
    }

script.
    $('.iconclick').click(function () {
        if ($(this).attr('name') == 'nolabe') {
            $(this).html('&#xe616;')
            $(this).css('color', '#46cad4')
            $(this).attr('name', 'yeslabe')
        } else {
            $(this).html('&#x1005;')
            $(this).css('color', '#aaaaaa')
            $(this).attr('name', 'nolabe')
        }
        $.ajax({
            url: '/agent/agentuserLabel.html',
            data: {'iconid': $(this).attr('id')},
            type: "get",
            success: function () {
            }
        });

    });

